<?php

namespace App\Services\Tools;

use App\Enums\ContentNameEnum;
use App\Enums\ContentTypeEnum;
use App\Jobs\Content\GroupFriendCardJob;
use App\Jobs\Content\GroupMessageJob;
use App\Models\MainDB\Group\GroupFriendCard;
use App\Models\MainDB\Group\GroupFriendCardTemp;

class GroupFriendCardAuditService
{
    /**
     * 推送数据到队列
     *
     * @param GroupFriendCard $card
     * @param string $nickName
     * @return void
     */
    public function audit(GroupFriendCardTemp $card, string $nickName = '')
    {
        $data = [
            'key_id' => $card->id,
            'user_id' => $card->user_id,
            'user_nickname' => $nickName,
            'content_name' => ContentNameEnum::GROUP_FRIEND_CARD,
            'content_type' => ContentTypeEnum::TEXT,
            'card_nickname' => $card->nickname,
            'content' => $card->introduction,
            'voices' => $card->voice,
            'pictures' => $card->pictures,
        ];
        $queueName = env('CONTENT_QUEUE_NAME');
        dispatch(new GroupFriendCardJob($data))->onQueue($queueName);
    }
}